BablFishPath touchups
authorØyvind Kolås <ok@src.gnome.org>
Mon, 19 Sep 2005 18:40:41 +0000 (18:40 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Mon, 19 Sep 2005 18:40:41 +0000 (18:40 +0000)
ChangeLog
babl/babl-conversion.c
babl/babl-fish-path.c
babl/babl-internal.c
docs/index-static.html.in
extensions/gggl.c
tests/babl_fish_path_dhtml.c

index c421930fe2c147e1e05c986108aec47c36831829..0c9857c084585f136ac1b2f8e3ae3cfc2a9b0053 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2005-09-19  Øyvind Kolås  <pippin@gimp.org>
+
+       BablFishPath touchups.
+
+       * babl/babl-conversion.c: cost = cost * 10 + 1, makes the overhead
+       of actually running a conversion 1. Removed stupid long pats from
+       created conversions.
+       * babl/babl-fish-path.c: (chain_gen_each): Ensure the chain doesn't
+       take us through larger loss than allowed.
+       * babl/babl-internal.c: (babl_extension_post_load): do not
+       autogenerate formats.
+       * docs/index-static.html.in: updating documentation.
+       * tests/babl_fish_path_dhtml.c: (table_destination_each),
+       (table_source_each), (main): recoded to use CSS tricks instead of
+       javascript, reduced generated file size by 50%;
+       * extensions/gggl.c: (conv_labF_xyzF), (conv_xyzF_labF): added missing
+       return value.
+
 2005-09-19  Øyvind Kolås  <pippin@gimp.org>
 
        * extensions/gggl.c: Added the bulk of gggl based conversions as an
index 976f4372f351c8143ab8df84134d158d6c5bd909..593110cdd41584f7cb1737d71c23f773e2b6a9c7 100644 (file)
@@ -522,7 +522,7 @@ babl_conversion_error (BablConversion *conversion)
   babl_free (test);
 
   conversion->error = error;
-  conversion->cost  = ticks_end-ticks_start;
+  conversion->cost  = (ticks_end-ticks_start)*10+1;
 
   return error;
 }
index 491ac6f27c9ab2542752a136f354ee0de3581963..a7e76cba50bdfc031a7922a1d02a8e258f6b6097 100644 (file)
@@ -198,6 +198,8 @@ chain_gen_each (Babl *babl,
           temp_loss = analytic_loss;
           
           if (error <= (1.0 + BABL_LEGAL_ERROR)  /* we're legal */ &&  
+              (temp_loss >= format_analytic_loss (c->from, c->to)) &&
+                  
              
               /* better than the existing best candidate */ 
               ( temp_loss <  *c->best_loss ||
index aacac8a738b60f874f095b3789fc9f68754785a6..555f672e5f4ae0174984fa7df50efafa000d8a1a 100644 (file)
@@ -160,6 +160,8 @@ babl_extension_post_load (void)
 {
   babl_conversion_each (each_conversion, NULL);
   babl_format_each     (each_format, NULL);
+    return;
   babl_model_each (gen_formats_for_model, NULL);
+  babl_format_each     (each_format, NULL);
 }
 
index 796632d0b25f9ce7be056355c8858d4d49d379e0..d776c15dd76f83ceeabf56df8c6c099cfc874aef 100644 (file)
         <h2>TODO</h2>
         
         <ul>
+          <li>Validate that BablFishPath is actually faster than the
+          BablFishReference it is a replacement for.</li>
           <li>Compile-time instead of runtime profiling / storae of profiling
           and loss data.. <em>(The speed of conversions
             is bound to 'wobble', according to architecture, compiler flags,
index a598de17a36aab6382d24a7647bb94f1689c9299..070d4cca0220339233f8c773f6c35e8951e885d6 100644 (file)
@@ -1624,6 +1624,7 @@ conv_labF_xyzF (unsigned char *src, unsigned char *dst, long samples)
       dst_f += 3;
       src_f += 3;
     }
+  return samples;
 }
 
 static INLINE long
@@ -1667,6 +1668,7 @@ conv_xyzF_labF (unsigned char *src, unsigned char *dst, long samples)
       dst_f += 3;
       src_f += 3;
     }
+  return samples;
 }
 
 /******* end of cpercep lift out **/
index 76949149866e5984ef7f7c05693914c54d642e43..ddd384fbc90bdb2e4a81fd45609d4f270d7c0721 100644 (file)
@@ -44,23 +44,50 @@ table_destination_each (Babl *babl,
 
       if (temp)
         {
-          printf ("<td class='cell'><a onmouseover='show(\"detail_%p\");' \
-                                       onmouseout='hide(\"detail_%p\");' \
-                                       href='javascript:tick()'>%s</a></td>",
-            temp, temp, utf8_bar[temp->fish_path.conversions]);
+          printf ("<td class='cell'><a href='javascript:o()'>%s",
+          utf8_bar[temp->fish_path.conversions]);
           total_length += temp->fish_path.conversions;
           total_cost   += temp->fish_path.cost;
+
+          {
+            int i;
+            printf ("<div class='tooltip'>");
+            printf ("<h3><span class='g'>path</span> %s <span class='g'>to</span> %s</h3>", source->instance.name, destination->instance.name);
+            printf ("<table>\n");
+
+                printf ("<tr>");
+                printf ("<td><em>conversion</em></td>");
+                printf ("<td style='text-align:right'><em>cost</em></td>");
+                printf ("</tr>");
+
+             for (i=0; i< temp->fish_path.conversions; i++)
+               {
+                printf ("<tr>");
+                printf ("<td>%s</td>", BABL(temp->fish_path.conversion[i])->instance.name);
+                printf ("<td class='r'>%i</td>", BABL(temp->fish_path.conversion[i])->conversion.cost);
+                printf ("</tr>");
+               }
+
+                printf ("<tr>");
+                printf ("<td><em>total</em></td>");
+                printf ("<td class='r'><em>%3.0f</em></td>", temp->fish_path.cost);
+                printf ("</tr>");
+            printf ("</table>\n");
+            printf ("</div>\n");
+          }
+          printf ("</a></td>");
           ok ++;
           total ++;
         }
       else
         {
-          printf ("<td class='cell'><a onmouseover='show(\"detail_%p_%p\");' \
-                                       onmouseout='hide(\"detail_%p_%p\");' \
-                                       href='javascript:tick()'>%s</a></td>",
-            source, destination,
-            source, destination,
-            "&nbsp");
+          printf ("<td class='cell'><a href='javascript:o()'>%s", "&nbsp");
+          {
+            printf ("<div class='tooltip'>");
+            printf ("<h3><span class='g'>Reference</span> %s <span class='g'>to</span> %s</h3>", source->instance.name, destination->instance.name);
+            printf ("</div>\n");
+          }
+          printf ("</a></td>");
         }
     }
   return 0;
@@ -101,96 +128,37 @@ table_source_each (Babl *babl,
     }
   
   printf ("<tr>");
-  printf ("<td class='format_name'><a onmouseover='show(\"format_%p\");' \
-                                   onmouseout='hide(\"format_%p\");' \
-                                   href='javascript:tick();'>%s</a></td>", 
-                                   babl, babl, expanded_name);
+  printf ("<td class='format_name'><a href='javascript:o();'>%s", expanded_name);
+  {
+    int i;
+
+    printf ("<div class='tooltip' id='format_%p'>", babl);
+    printf ("<h3>%s</h3>", babl->instance.name);
+
+    printf ("<dl>");
+    printf ("<dt>bytes/pixel</dt><dd>%i</dd>", babl->format.bytes_per_pixel);
+    printf ("<dt>model</dt><dd>%s</dd>", BABL(babl->format.model)->instance.name  );
+    printf ("<dt>loss</dt><dd>%f</dd>", babl->format.loss );
+    printf ("<dt>components</dt><dd><table class='nopad'>");
+
+    for (i=0; i< babl->format.components; i++)
+      {
+        printf ("<tr><td class='type'>%s</td><td class='component'>%s</td></tr>",
+         BABL(babl->format.type[i])->instance.name,
+         BABL(babl->format.component[i])->instance.name  );
+      }
+    printf ("</table></dd></dl>");
+
+    printf ("</div>\n");
+  }
+
+  printf ("</a></td>");
   babl_format_each (table_destination_each, babl);
   printf ("</tr>\n");
   source_no++;
   return 0;
 }
 
-
-
-static int
-detail_destination_each (Babl *babl,
-                        void *userdata)
-{
-  Babl *source = userdata;
-  Babl *destination = babl;
-
-  Babl *temp = babl_fish_path (source, destination);
-
-  if (temp)
-    {
-      int i;
-      printf ("<div class='detail' style='display:none' id='detail_%p'>", temp);
-      printf ("<h3><span style='color:gray'>path</span> %s <span style='color:gray'>to</span> %s</h3>", source->instance.name, destination->instance.name);
-      printf ("<table>\n");
-          printf ("<tr>");
-          printf ("<td><em>conversion</em></td>");
-          printf ("<td style='text-align:right'><em>cost</em></td>");
-          printf ("</tr>");
-       for (i=0; i< temp->fish_path.conversions; i++)
-         {
-          printf ("<tr>");
-          printf ("<td>%s</td>", BABL(temp->fish_path.conversion[i])->instance.name);
-          printf ("<td style='text-align:right'>%i</td>", BABL(temp->fish_path.conversion[i])->conversion.cost);
-          printf ("</tr>");
-         }
-          printf ("<tr>");
-          printf ("<td><em>total</em></td>");
-          printf ("<td style='text-align:right'><em>%3.0f</em></td>", temp->fish_path.cost);
-          printf ("</tr>");
-      printf ("</table>\n");
-      printf ("</div>\n");
-    }
-  else
-    {
-      printf ("<div class='detail' style='display:none' id='detail_%p_%p'>", source, destination);
-      printf ("<h3><span style='color:gray'>Reference</span> %s <span style='color:gray'>to</span> %s</h3>", source->instance.name, destination->instance.name);
-      printf ("</div>\n");
-    }
-  return 0;
-}
-
-static int
-detail_source_each (Babl *babl,
-                    void *userdata)
-{
-  babl_format_each (detail_destination_each, babl);
-  return 0;
-}
-
-static int
-format_each (Babl *babl,
-             void *userdata)
-{
-  int i;
-
-  printf ("<div class='detail' style='display:none' id='format_%p'>", babl);
-  printf ("<h3>%s</h3>", babl->instance.name);
-
-  printf ("<dl>");
-  printf ("<dt>bytes/pixel</dt><dd>%i</dd>", babl->format.bytes_per_pixel);
-  printf ("<dt>model</dt><dd>%s</dd>", BABL(babl->format.model)->instance.name  );
-  printf ("<dt>loss</dt><dd>%f</dd>", babl->format.loss );
-  printf ("<dt>components</dt><dd><table class='nopad'>");
-
-  for (i=0; i< babl->format.components; i++)
-    {
-      printf ("<tr><td class='type'>%s</td><td class='component'>%s</td></tr>",
-       BABL(babl->format.type[i])->instance.name,
-       BABL(babl->format.component[i])->instance.name  );
-    }
-  printf ("</table></dd></dl>");
-
-  printf ("</div>\n");
-  return 0;
-}
-
-
 int main (void)
 {
   babl_init ();
@@ -218,23 +186,23 @@ int main (void)
    "  padding: 0;"
    "  margin : 0;"
    "}"
-   " .cell>a {"
+   ".cell>a {"
    "    text-decoration: none;"
    "    color: black;"
    "    cursor: help;"
    "}"
-   " .detail {"
+   "div.tooltip {"
    "   border: 0.2em solid black;"
    "   padding-top: 1em;"
    "   padding-right: 2em;"
+   "   display: none;"
    "   padding-left: 2em;"
    "   padding-bottom: 3em;"
    "   background-color: white;"
-   "}"
-   "#tooltip {"
-   "   position: fixed;"
-   "   bottom: 0;"
-   "   right : 0;"
+   "   background-repeat: no-repeat;"
+   "   background-image: url(graphics/babl-48x48.png);"
+   "   background-position: bottom right;"
+   "   color: black;"
    "}"
    " .cell>a:hover {"
    "  background-color: black;"
@@ -257,6 +225,13 @@ int main (void)
    "  color: white;"
    " }"
 
+   "a:hover>div.tooltip {"
+   "   display: block;"
+   "   position: fixed;"
+   "   bottom: 0;"
+   "   right: 0;"
+   "}"
+
    "td.component {"
    "  background-color: #060;"
    "  padding-left: 0.5em;"
@@ -277,26 +252,25 @@ int main (void)
    "  color: white;"
    "  border: 1px solid white;"
    "}"
+   ".g {"
+   "  color: gray;"
+   "}"
+   ".r {"
+   "  text-align: right;"
+   "}"
 
    "</style>"
 
 "<script type='text/javascript'>"
 "var tick_count=0;"
-"function tick ()"
+"function o ()"
 "{"
 "   tick_count++;"
-"   if (tick_count > 42)"
-"        alert(\"Clicking doesn't do anything.\");"
+"   if (tick_count == 11)"
+"        alert(\"«The mind is it's own place,\\nand in itself can make a heaven of hell;\\na hell of heaven.»\\n--Milton\");"
+"   else if (tick_count == 42)"
+"        alert(\"«So long and thanks for all the fish.»\\n--Adams\");"
 "}"
-"function hide (id)"
-"{"
-"  (document.getElementById (id)).style.display = \"none\";"
-"}"
-"function show (id)"
-"{"
-"  (document.getElementById (id)).style.display = \"block\";"
-"}"
-
 "</script>"
 
 
@@ -306,18 +280,12 @@ int main (void)
 
   printf ("<h1>BablFishPath introspection</h1>");
   printf ("<p>The table below represents many of the possible conversions available through babl, (the selection of formats includes all formats that shortcut conversions have been registered for.) </p>");
-  printf ("<p>Hover your mouse over a formats name, or a non blank cell on the horizontal line to see further information </p>");
+  printf ("<p>Hover your mouse over a formats name, or a non blank cell on the horizontal line to see further information, both rows and colums represent pixel formats, but only the vertical axis has labels.</p>");
 
-  printf ("<br/><img src='graphics/babl-48x48.png' alt='/babl' />");
   printf ( "<table cellspacing='0'>\n");
   babl_format_each (table_source_each, NULL);
   printf ("</table>");
 
-  printf ("<div id='tooltip'>");
-  babl_format_each (detail_source_each, NULL);
-  babl_format_each (format_each, NULL);
-  printf ("</div>");
-
   printf ("<div style='height:20em'></div>\n");
 
   printf ("</body></html>\n");